package com.xwh.week4;

import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;

public class Practice8 {
    static Set<String> set= new TreeSet();
    public static void main(String[] args) {
     for(int i=9234;i<=9487;i++){
      method(i);
     }
        System.out.println(set);
    }
    public static void method(int n){
        StringBuilder s = new StringBuilder();
        s.append(n);
        s.append(n*2);
        if( method1(n,n*2)){
            String s1=new String(s);
            set.add(s1);
        }
    }
    public static boolean method1(int n1,int n2){
        int[] arrays=new int[9];
        int i=0;
        while(n1>0){
            arrays[i++]=n1%10;
            n1/=10;
        }
        while(n2>0){
            arrays[i++]=n2%10;
            n2/=10;
        }
        Arrays.sort(arrays);
        for(int j=0;j<9;j++){
            if(arrays[j]!=j+1){
                return false;
            }
        }
       return true;
    }
}
